Skip to content

fix: emit expression case values for IF flows#492

Merged
ako merged 1 commit intomendixlabs:mainfrom
hjotha:submit/boolean-split-case-values
May 2, 2026
Merged

fix: emit expression case values for IF flows#492
ako merged 1 commit intomendixlabs:mainfrom
hjotha:submit/boolean-split-case-values

Conversation

@hjotha
Copy link
Copy Markdown
Contributor

@hjotha hjotha commented May 2, 2026

Closes #491.

Summary

  • represent true/false IF sequence-flow cases as expression cases internally
  • keep enumeration case values for real enum split values
  • serialize expression cases as expression cases for modern MPRs
  • downgrade expression cases to enumeration-style values when writing Mendix 9 projects
  • update guard and nested enum-split tests to assert the correct case semantics

Validation

  • make build
  • make test
  • make lint-go

@hjotha hjotha force-pushed the submit/boolean-split-case-values branch 2 times, most recently from 4c3a2c0 to 557016e Compare May 2, 2026 15:13
@hjotha hjotha changed the title fix: emit boolean case values for IF flows fix: emit expression case values for IF flows May 2, 2026
Symptom: consistency validation can report duplicate output variables for values declared in mutually exclusive IF branches after exec builds the graph. A targeted Mendix 9 validation pass also showed that emitting ExpressionCase directly breaks legacy MPRs because that metamodel stores boolean branches as enumeration-style case values.

Root cause: IF sequence flows used EnumerationCase values as the only in-memory representation. That conflates IF branch cases with real enum split cases, but the writer also needs to honor the target Mendix version when serializing the case object.

Fix: represent true/false IF branch flows as ExpressionCase internally, keep EnumerationCase for real enum split values, serialize ExpressionCase as ExpressionCase for modern MPRs, and downgrade it to EnumerationCase when writing Mendix 9 projects.

Tests: make build, make test, make lint-go.
@hjotha hjotha force-pushed the submit/boolean-split-case-values branch from 557016e to ee8d0a8 Compare May 2, 2026 15:20
@ako
Copy link
Copy Markdown
Collaborator

ako commented May 2, 2026

Review: fix: emit expression case values for IF flows

Verdict: Approve with minor notes

What the PR does

Fixes issue #491: mxcli was serializing IF-branch sequence flows as Microflows$EnumerationCase (string "true"/"false") when Studio Pro 10+ expects Microflows$ExpressionCase (field Expression). The fix introduces caseValueForFlow to correctly produce *ExpressionCase for boolean branches and EnumerationCase for real enum values, with a version-gate in buildSequenceFlowCase that downgrades ExpressionCase → EnumerationCase when writing Mendix 9 projects.

No blockers

Moderate concern

No DESCRIBE roundtrip test (Recurring Finding #4)

The PR adds unit tests for caseValueForFlow and buildSequenceFlowCase, but no test that builds a microflow with an IF split, serializes it, re-parses it, and confirms DESCRIBE produces correct MDL. This is exactly the gap the roundtrip finding covers. A failing Studio Pro project won't fail make test, so the regression can resurface silently if the new case type is mishandled anywhere in the show/format path.

Suggested: add a test in mdl/executor/ that creates a microflow with an IF branch, calls the BSON serializer, re-parses, then calls showMicroflowActivities and asserts the output contains if ... then rather than garbage.

Minor issues

flowCaseString handles only pointer *ExpressionCase, not value form

The updated flowCaseString test helper only matches *microflows.ExpressionCase. If any test creates a value-form ExpressionCase{} directly and passes it through flowCaseString, it silently returns "". In practice all production paths (caseValueForFlow, parser) produce pointers, so this is unlikely to bite, but it's inconsistent with how EnumerationCase is handled (both forms).

Positive notes

  • Clean PR — no bundled unrelated changes
  • The existing findBranchFlows already handled *ExpressionCase pre-PR; BooleanCase handling retained for legacy MPR files
  • Version gate (majorVersion <= 9) correctly aligns with the NewCaseValue vs CaseValues[] serialization split already in the writer
  • Two new writer tests explicitly cover Mx9 downgrade and Mx10+ path — this is exactly the right level of coverage for version-specific serialization

@ako ako merged commit 9ac2bb0 into mendixlabs:main May 2, 2026
2 checks passed
ako added a commit that referenced this pull request May 2, 2026
PR #492 changed boolean IF-branch flows from EnumerationCase to
ExpressionCase. The regression test was asserting on the old type directly;
switch to flowCaseString() to handle all CaseValue variants uniformly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IF sequence flows should emit ExpressionCase values

3 participants